/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-1-13 上午11:43 Created by dwzhang
 */
package com.jade.framework.web.spring;

import javax.servlet.ServletContext;
import com.jade.framework.base.context.ApplicationContextUtils;
import com.jade.framework.base.context.JadeApplicationContext;
import com.jade.framework.base.context.SpringApplicationContext;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ContextLoaderListener;

/**
 * 把外面的context设置为Parent context.
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-1-13 上午11:43
 */
public class JadeContextLoaderListener   extends ContextLoaderListener
{
    @Override
    protected void customizeContext(ServletContext sc, ConfigurableWebApplicationContext wac)
    {
        JadeApplicationContext ac = ApplicationContextUtils.getApplicationContext();
        if (ac instanceof SpringApplicationContext) {
            wac.setParent(((SpringApplicationContext) ac).getApplicationContext());
        }
    }
}
